<%@ page import="java.util.HashMap,common.CommonUtil,java.util.*,common.*,java.text.*" contentType="text/html; charset=utf-8" %>
<%@ taglib uri="/WEB-INF/commontags.tld" prefix="common" %><%--페이징처리tag--%>
<%
UserSession userSession = (UserSession)session.getAttribute("user"); 

String login_id = null;
String user_id = null;
String level = null;
String admin_ent_id = null;

if(userSession!= null){
	login_id = userSession.getLogin_id();
	user_id = userSession.getUser_id();
	level = userSession.getAdmin_level();
	admin_ent_id = userSession.getEnt_id();
}

String s_test_state 	= CommonUtil.nvl(request.getParameter("test_state"),"");
String s_rating_state 	= CommonUtil.nvl(request.getParameter("rating_state"),"");

String search_combo 	= CommonUtil.nvl(request.getParameter("search_combo"),"");
String keyword 		= CommonUtil.nvl(request.getParameter("keyword"),"");
String line_number	= CommonUtil.nvl(request.getParameter("line_number"),"10");
//페이징 처리 Start
//페이지 표시정보 받기 혹은 검색입력창
String curr_page = CommonUtil.nvl(request.getParameter("curr_page"),"1");

String one_group = CommonUtil.nvl(request.getParameter("one_group"),"10");
String total_count = CommonUtil.nvl(request.getParameter("total_count"),"0");
//페이징 처리 End

String ent_id	= CommonUtil.nvl(request.getParameter("ent_id"),""); 
String gubun	= CommonUtil.nvl(request.getParameter("gubun"),""); 
String start_date	= CommonUtil.nvl(request.getParameter("start_date"),""); 
String end_date	= CommonUtil.nvl(request.getParameter("end_date"),"");

/*
if(gubun.equals("")){
	gubun = "OPIC";
}
*/

//지정일
SimpleDateFormat tf = new SimpleDateFormat ("yyyy-MM-dd");
Calendar sday =new GregorianCalendar();
sday.set(Integer.parseInt(CommonUtil.getToday("yyyy")), Integer.parseInt(CommonUtil.getToday("MM"))-2, Integer.parseInt(CommonUtil.getToday("dd")));

if(start_date.equals("")){
	start_date = tf.format(sday.getTime());
}

if(end_date.equals("")){
	end_date = CommonUtil.getToday("yyyy")+"-"+CommonUtil.getToday("MM")+"-"+CommonUtil.getToday("dd");
}

String[] start_date_arr = start_date.split("-");
String[] end_date_arr = end_date.split("-");
%>
<jsp:include page="/jsp/common/header.jsp"></jsp:include>

<meta http-equiv="X-UA-Compatible" content="IE=7" />

<script language='javascript' src="/js/ajaxutil.js"></script>
<script language='javascript' src="/js/calendar.js"></script>
<script>

//검색
function key_check(){
 //alert("키번호는 [" +event.keyCode+ "] 입니다.");
 if(event.keyCode==13){
	 go_search();
 }
}
function go_search(){
	var frm = document.mainform;
	
	var start_date_arr = frm.start_date.value.split('-');
	var s_year = start_date_arr[0];
	var s_month = Lpad(start_date_arr[1], 2);
	var s_day = Lpad(start_date_arr[2], 2);
	
	frm.start_date.value = s_year+'-'+s_month+'-'+s_day;
	
	var end_date_arr = frm.end_date.value.split('-');
	var e_year = end_date_arr[0];
	var e_month = Lpad(end_date_arr[1], 2);
	var e_day = Lpad(end_date_arr[2], 2);
	
	frm.end_date.value = e_year+'-'+e_month+'-'+e_day;
	
	var chk_start_dt = s_year+s_month+s_day;
	var chk_end_dt = e_year+e_month+e_day;
	
	if(chk_start_dt > chk_end_dt){
		alert('시작일이 종료일보다 큽니다.');
		return;
	}
	
	/*
	frm.cmd.value='statistics_ent';
	frm.action = "/speaking.pb";
	frm.target="_self";
	frm.submit();
	*/
	<%if(level.equals("1")){ %>
	go_ent_list_1();
	go_ent_list_2();
	<%}%>
	go_ent_list_3();
}

function go_opictest(){
	go_search();
}

function go_tstest(){
	go_search()
}


function go_excel(){
	var frm = document.mainform;	
	frm.action = '/jsp/sp_sp0501_ent_excel.jsp';
	frm.target= 'hidden_frm';              
	frm.submit();	
}



function go_ent_list_1(){
	/*
	var frm = document.mainform;
	frm.cmd.value="statistics_ent_1";
	frm.action = '/speaking.pb';
	frm.target= 'ent_list_1';              
	frm.submit();
	*/
}

function go_ent_list_2(){
	/*
	var frm = document.mainform;
	frm.cmd.value="statistics_ent_2";
	frm.action = '/speaking.pb';
	frm.target= 'ent_list_2';              
	frm.submit();
	*/
}

function go_ent_list_3(){
	var frm = document.mainform;
	frm.cmd.value="statistics_ent_3";
	frm.action = '/speaking.pb';
	frm.target= 'ent_list_3';              
	frm.submit();
}
</script>
<script>

<%if(!level.equals("5")){ %>
function init_member(){
	form = document.mainform;
	setSPSelect(form.ent_id,'<%=ent_id%>', '기업선택', 'ent');
	
	<%if(level.equals("1")){ %>
	go_ent_list_1();	
	go_ent_list_2();
	<%}%>
	go_ent_list_3();
	
}
window.onload = init_member;
<%}%>

<%if(level.equals("5")){ %>
function init_member(){
	form = document.mainform;
	
	go_ent_list_3();
	
}
window.onload = init_member;
<%}%>
</script>
<jsp:include page="/jsp/common/top.jsp"></jsp:include>
<jsp:include page="/jsp/common/submenu.jsp"><jsp:param name="submenu_id" value="statistics_ent" /><jsp:param name="submenu_idx" value="3" /></jsp:include>

<form name="mainform"  method="post" action = "/speaking.pb" >
<input type="hidden" name="cmd" value="">
<input type="hidden" name="e_total_count" value="">

<input type="hidden" name="user_id" value="<%=user_id %>">
<input type="hidden" name="member_test_code" value="">

	<div id="bodyContainer">
        <div id="contents">
          
          <!-- 
          <div style="padding-left:30px;padding-top:10px">
          <table style="border:1px solid #d0d0d0;background:#e4e4e4;">
          <tr><td>
           -->
          <br>
          <div class="select_menu3">
            <ul>
              <li class="mt5"><b>● 응시 시작/종료일  </b></li>
              <li class="mt5">시작일 :</li>
              <li class="mt2"><INPUT TYPE="text" style="width:70px" NAME="start_date"  id="start_date" value="<%=start_date %>" OnFocus=cal(<%=start_date_arr[0] %>,<%=start_date_arr[1] %>,<%=start_date_arr[2] %>,this);></li>
              <li class="mt5">~</li>
			  <li class="mt5">종료일 :</li>             
              <li class="mt2"><INPUT TYPE="text" style="width:70px"  NAME="end_date"  id="end_date" value="<%=end_date %>" OnFocus=cal(<%=end_date_arr[0] %>,<%=end_date_arr[1] %>,<%=end_date_arr[2] %>,this);></li>
              <li class="mt2" style="padding-left:490px"><a href="#" onclick="go_excel()"><img src="img/btn_excel.gif" alt="excel" /></a></li>
             </ul>
          </div>
          <%if(!level.equals("5")){ %>
          <div class="select_menu3">
          	<ul>
          	  <li class="mt5"><b>● 기업선택  </b></li>
             <li style="padding-left:4px">&nbsp; </li>
              <li class="mt2">              
              	<select name="ent_id" id="ent_id" style="width:100px" onchange="go_search()">
                  <option value=''>기업선택</option>
                </select>
              </li>
              
            </ul>
           </div>
           <%}else{ %>
              <input type="hidden" name="ent_id" value="<%=admin_ent_id %>">
           <%} %>  
           
           <div class="select_menu3">
          	<ul>
          	  <li class="mt5"><b>● 시험구분  </b></li>  
          	 <li style="padding-left:4px">&nbsp; </li>
              <li class="mt2">
              	<select name="gubun" id="gubun" style="width:100px" onchange="go_search()">
                  <option value=''>시험구분</option>
                  <option value='OPIC' <%=(gubun.equals("OPIC")?"selected":"") %>>OPIC</option>
                  <option value='TS' <%=(gubun.equals("TS")?"selected":"") %>>T/S</option>
                </select>  
              </li>
              
            </ul>
          </div>
          
          
          <div class="select_menu3">
            <ul>
              <li class="mt5"><b>● 시험상태  </b></li>
              <li style="padding-left:4px">&nbsp; </li>
              <li class="mt2"><select name="test_state" id="test_state" style="width:100px" onchange="if(this.value=='2'){rating_state_select.style.display='block'}else{rating_state_select.style.display='none';document.mainform.rating_state[0].selected=true;} go_search();">
                <option value=''>시험상태</option>
                <option value=0 <%=(s_test_state.equals("0"))?"selected":"" %>>진행전</option>
                <option value=1 <%=(s_test_state.equals("1"))?"selected":"" %>>진행중</option>
                <option value=2 <%=(s_test_state.equals("2"))?"selected":"" %>>완료</option>
                <!-- 
                <option value=8 <%=(s_test_state.equals("8"))?"selected":"" %>>무채점완료</option>
                -->
                <option value=9 <%=(s_test_state.equals("9"))?"selected":"" %>>재시험</option>
                <option value='pa' <%=(s_test_state.equals("pa"))?"selected":"" %>>일시정지</option>
                <option value='br' <%=(s_test_state.equals("br"))?"selected":"" %>>시험중단</option>
                <option value='R' <%=(s_test_state.equals("R"))?"selected":"" %>>환불</option>
              </select></li>
              
              
            </ul>
          </div>
          
          <div class="select_menu3" style="display:none" id="rating_state_select">
            <ul> 
              <li class="mt5"><b>● Rating상태 </b></li> 
                        
              <li  class="mt2" ><select name="rating_state" id="rating_state" style="width:100px" onchange="go_search()">
                <option value=''>Rating상태</option>
                <option value=0 <%=(s_rating_state.equals("0"))?"selected":"" %>>진행전</option>
                <option value=1 <%=(s_rating_state.equals("1"))?"selected":"" %>>진행중</option>
                <option value=2 <%=(s_rating_state.equals("2"))?"selected":"" %>>완료</option>
                <!-- <option value=9 <%=(s_rating_state.equals("9"))?"selected":"" %>>재시험</option>  -->
                <option value=10 <%=(s_rating_state.equals("10"))?"selected":"" %>>보류</option>
              </select></li>
            </ul>
          </div>
              
          <div class="select_menu3">
            <ul>    
              <li class="mt5"><b>● 검색어 선택  </b></li> 
              <li class="mt2"><select name="search_combo" id="search_combo" style="width:120px">
                <option value=''>이름/아이디 선택</option>
                <option value=1 <%=(search_combo.equals("1"))?"selected":"" %>>이름</option>
                <option value=2 <%=(search_combo.equals("2"))?"selected":"" %>>아이디</option>
              </select></li>
              <li class="mt2"><input type="text" name="keyword" id="keyword" style="width:200px" value="<%=keyword %>" onKeyDown="javascript:key_check()" /></li>
              <li class="mt2"><a href="#" onclick="go_search()"><img src="img/btn_search.gif" alt="search" /></a></li>
              
              
            </ul>
          </div>
          
          <!-- 
          </td></tr>
          </table>
          </div>
           -->
          
          <%if(level.equals("1")){ %>
          <!-- 
          <iframe name='ent_list_1'  width='1080' height='120' SCROLLING='no' frameborder='0'></iframe>
          
          <iframe name='ent_list_2'  width='1080' height='400' SCROLLING='AUTO' frameborder='0'></iframe>
           -->
          <%} %>
          
          <iframe name='ent_list_3'  width='1080' height='470' SCROLLING='no' frameborder='0'></iframe>
                   
          
          
        </div>
      </div>



</form>

<iframe name='hidden_frm'  width='0' height='0' SCROLLING='AUTO' frameborder='0'></iframe>
<jsp:include page="/jsp/common/footer.jsp"></jsp:include>
<jsp:include page="/jsp/common/bottom.jsp"></jsp:include>
